package com.bjpowernode.app;
import java.util.InputMismatchException;
import java.util.Scanner;
public class MyApp7 {
    public static void main(String[] args) {
        try {
            int[] a = {10, 20, 30};
            Scanner scanner = new Scanner(System.in);
            //用户输入的数组下标
            int i = scanner.nextInt();
            //输出数组的数据
            System.out.println(a[i]);
        }
        //处理输入的不是数字
        catch (InputMismatchException e) {
            System.out.println("你输入的不是数字，出错了...");
        }
        //处理数组超标
        catch (ArrayIndexOutOfBoundsException e) {
            System.out.println("你输入的数字超标，出错了...");
        }
        //补一个遗漏的Exception
        catch (Exception e) {
            e.printStackTrace();
            System.out.println("还没有发现的错误,出错了...");
        }
        //程序运行完毕
        System.out.println("bye!!!");
    }
}
